window.onload = function () {
    var box1 = document.getElementById("box1");
    box1.onmousedown = function (event) {
        event = event||window.event;
        var ol = event.clientX-box1.offsetLeft;
        var ot = event.clientY-box1.offsetTop;


        document.onmousemove = function (event) {
            event = event || window.event;
            var left = event.clientX-ol;
            var top = event.clientY-ot;

            box1.style.left = left + "px";
            box1.style.top = top + "px";

        };

        document.onmouseup = function () {
            document.onmousemove = null;
            console.log("1");
            document.onmouseup = null;
        }
    };
};